package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.OrderDao;
import com.coolbi.onsupai.core.entity.Order;
import com.coolbi.onsupai.core.mapper.OrderMapper;

public class OrderDaoImpl implements OrderDao {

	@Autowired
	private OrderMapper orderMapper;
	public void setOrderMapper(OrderMapper orderMapper) {
		this.orderMapper = orderMapper;
	}
	
	@Override
	public Order save(Order obj) {
		orderMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return orderMapper.delete(id);
	}

	@Override
	public int update(Order obj) {
		return orderMapper.update(obj);
	}

	@Override
	public Order get(long id) {
		return orderMapper.get(id);
	}

	@Override
	public List<Order> list() {
		return orderMapper.list();
	}

	@Override
	public List<Order> listByPage(int offset, int limit) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return orderMapper.listByPage(parameter);
	}

	@Override
	public List<Order> find(Map<String, Object> parameter) {
		return orderMapper.listByParameter(parameter);
	}

	@Override
	public List<Order> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return orderMapper.listByParameterPage(parameter);
	}

	@Override
	public List<Order> search(Map<String, Object> parameter, int offset,
			int limit) {
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return orderMapper.search(parameter);
	}

	@Override
	public int count() {
		return orderMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return orderMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return orderMapper.countByParameter(parameter);
	}

	@Override
	public List<Order> findByIds(List<Long> orderIds) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("orderIds", orderIds);
		return orderMapper.findByIds(parameter);
	}

	@Override
	public int confirmOrderConsign(Long id, int orderStatus) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("id", id);
		parameter.put("orderStatus", orderStatus);
		return orderMapper.confirmOrderConsign(parameter);
	}
	
	@Override
	public int modifyOrderStatus(Long id, int orderStatus) {
		Map<String, Object> parameter = new HashMap<String, Object>();
		parameter.put("id", id);
		parameter.put("orderStatus", orderStatus);
		return orderMapper.modifyOrderStatus(parameter);
	}

}
